package com.wanwu.channel.dao.inter;

import com.wanwu.channel.dao.condition.BaseCondition;
import com.wanwu.channel.dao.entity.ChannelApplyClearanceEntity;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

public interface ChannelApplyClearanceDao {

    int insert(ChannelApplyClearanceEntity record);

    int insertSelective(ChannelApplyClearanceEntity record);

    ChannelApplyClearanceEntity selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(ChannelApplyClearanceEntity record);

    int updateByPrimaryKey(ChannelApplyClearanceEntity record);

    /**
     * 通过报关渠道号查询报关申请信息
     * @param channelNo
     * @return
     */
    ChannelApplyClearanceEntity selectByChannelNo(@Param("channelNo") String channelNo);

    ChannelApplyClearanceEntity selectByChannelNoFMaster(@Param("channelNo") String channelNo);

    /**
     * 通过支付单号+报关子单号查询最新报关申请单
     * @param subOrderNo
     * @return
     */
    ChannelApplyClearanceEntity selectBySubOrderNo(@Param("subOrderNo") String subOrderNo, @Param("bizCode") String bizCode);

    ChannelApplyClearanceEntity selectBySubOrderNoFMaster(@Param("subOrderNo") String subOrderNo, @Param("bizCode") String bizCode);

    /**
     * 根据报关渠道号更新报关结果
     * @param record
     * @return
     */
    int updateByChannelNo(ChannelApplyClearanceEntity record);


    ChannelApplyClearanceEntity selectByBizOrderNoAndSubBizOrderNo(@Param("bizOrderNo") String bizOrderNo, @Param("subBizOrderNo") String subBizOrderNo, @Param("bizCode") String bizCode);

    ChannelApplyClearanceEntity selectByBizOrderNoAndSubBizOrderNoFMaster(@Param("bizOrderNo") String bizOrderNo, @Param("subBizOrderNo") String subBizOrderNo, @Param("bizCode") String bizCode);

    // 以下是后台的方法
    Integer countNum(@Param("entity") ChannelApplyClearanceEntity entity, @Param("cond") BaseCondition condition);

    List<ChannelApplyClearanceEntity> qryList(@Param("entity") ChannelApplyClearanceEntity entity, @Param("cond") BaseCondition condition);

    List<ChannelApplyClearanceEntity> qryListByTime(@Param("id") Long id,
                                                    @Param("startDate") Date startDate,
                                                    @Param("endDate") Date endDate,
                                                    @Param("clearanceStatus") List<Integer> clearanceStatus,
                                                    @Param("payTypes") List<Integer> payTypes,
                                                    @Param("start") Long start,
                                                    @Param("count") Long count);
}